# Contributor: Denis Ryabyy <vv1r0x@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtserialport
pkgver=5.15.5_git20220602
pkgrel=0
_commit="112fcd80658a52e6a2822ec79a7d724d0ad003cf"
pkgdesc="Qt5 - QtSerialPort module"
url="https://wiki.qt.io/QtSerialPort"
arch="all"
license="(LGPL-2.0-or-later OR GPL-3.0-only OR GPL-2.0-or-later) AND Qt-GPL-exception-1.0"
makedepends="
	eudev-dev
	qt5-qtbase-dev
	"
subpackages="$pkgname-dev"
builddir="$srcdir/qtserialport-$_commit"

case $pkgver in
	*_beta*|*_rc*) _rel=development_releases;;
	*) _rel=official_releases;;
esac

source="https://invent.kde.org/qt/qt/qtserialport/-/archive/$_commit/qtserialport-$_commit.tar.gz"

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make
}

check() {
	make check
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

	install -d "$pkgdir"/usr/share/licenses
	ln -s /usr/share/licenses/qt5-base "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
b7e608ba88c6578ae1edc9ce6646460422214daaf39a0bfe28c81780dc291a17ff193a4d28c6dd36dbd028d91ec582f96a63aa5a5ff3f3c77d693d981095826f  qtserialport-112fcd80658a52e6a2822ec79a7d724d0ad003cf.tar.gz
"
